
******************************************
*******Transcription Data Mngmt***********
******************************************
clear all
set more off




//Saving excel sheets in dta format
if 1 {
import excel "data/raw/TranscriptionCodingRachel.xlsx", sheet("Questions") firstrow clear
gen transcriber="Rachel"
drop if Session==12
save "data/Rachel.dta", replace

import excel "data/raw/TranscriptionCodingJustinCopy.xlsx", sheet("Questions") firstrow clear
gen transcriber="Justin"
drop if Session==29
destring Didtheparticipantstalkabout, replace force
destring QualityTranscribersView, replace
save "data/Justin.dta", replace

import excel "data/raw/TranscriptionCodingArjun.xlsx", sheet("Questions") firstrow clear
gen transcriber="Arjun"
destring Didtheparticipantstalkabout, replace force
drop if Session>=8 //Keeping only Sessions 3 to 7 from Arjun
save "data/Arjun.dta", replace

import excel "data/raw/TranscriptionCodingJihun.xlsx", sheet("Questions") firstrow clear
gen transcriber="Jihun"
save "data/Jihun.dta", replace

}

//Appending transcription files
use "data/Rachel.dta", clear
append using "data/Justin.dta", force
append using "data/Arjun.dta", force
append using "data/Jihun.dta", force

//Renaming variables
rename AK notes
rename SpeakerAWordcountTranscriber SpeakerAWordcountTrans1
rename SpeakerBWordCountTranscriber SpeakerBWordcountTrans1 
rename K SpeakerAWordcountTrans2
rename L SpeakerBWordcountTrans2
rename Didparticipantstalkaboutthe talkAboutVideos
rename Didtheparticipantstalkabout talkAboutrule
rename WhichformuladidSpeakerAuse formulaSpeakerA
rename WhichformuladidSpeakerBuse formulaSpeakerB
rename Howmanydecisionproblemsdidt numberOfProbDiscussed
rename Inhowmanydecisionproblemssu numberOfProbDiscussedFV
rename S numberOfProbDiscussedPV
rename T numberOfProbAgreedFV
rename U numberOfProbAgreedPV
rename Splitbetweensmalltalkanddec smallTalkvsTask
rename Isthecommunicationsymmetric commSymmetric
rename Didoneoftheparticipantstry convinceKnowledgeable
rename Discusspaymentsmarketinterest paymentMarketIntRate
rename DiscusspaymentsAmazonGiftCar paymentAmazonGift
rename Discusspaymentstrustinexperi paymenttrustExp
rename Discusspaymentssoonerlaterpa paymentLikelihood
rename Discusspaymentsother paymentOther


encode TreatmentControl, gen(treatmentStatus)
drop TreatmentControl

encode transcriber, gen(transcriberName)
drop transcriber

drop idOwn //This doesn't have a meaning since we don't know whether Speaker A is 1 or 2.

///Adding the labels
//Gender
label define gender_lbl 0 `"Female"', add 
label define gender_lbl 1 `"Male"', add 
label define gender_lbl 99 `"Unclear"', add 
label values SpeakerAgender gender_lbl 
label values SpeakerBgender gender_lbl 

//Accent
label define accent_lbl 0 `"British"', add 
label define accent_lbl 1 `"Asian"', add 
label define accent_lbl 2 `"Other"', add 
label define accent_lbl 99 `"Unclear"', add 
label values SpeakerAaccent accent_lbl 
label values SpeakerAaccent accent_lbl 

//Talk about Videos
label define talkVideos_lbl 0 `"Not talked"', add 
label define talkVideos_lbl 1 `"DocEduc"', add 
label define talkVideos_lbl 2 `"EducDoc"', add 
label define talkVideos_lbl 3 `"bothDoc"', add 
label values talkAboutVideos talkVideos_lbl

//Talk about Rule
label define talkRule_lbl 0 `"No formula"', add 
label define talkRule_lbl 1 `"Rule of 72-explicit"', add 
label define talkRule_lbl 2 `"Rule of 72-not explicit"', add 
label define talkRule_lbl 3 `"Compound Interest"', add 
label define talkRule_lbl 4 `"Simple Interest"', add 
label define talkRule_lbl 5 `"Both 1 and 3 or both 2 and 3"', add 
label values talkAboutrule talkRule_lbl

//Use rule
label define useRule_lbl 0 `"No formula"', add 
label define useRule_lbl 1 `"Rule of 72"', add 
label define useRule_lbl 2 `"Compound Interest"', add 
label define useRule_lbl 3 `"Simple Interest"', add 
label values formulaSpeakerA useRule_lbl
label values formulaSpeakerB useRule_lbl

//Small Talk
label define smallTalk_lbl 0 `"No or Unclear"', add 
label define smallTalk_lbl 1 `"Yes"', add 
label values SmallTalkMajor smallTalk_lbl
label values SmallTalkYear smallTalk_lbl
label values SmallTalkFromWhere smallTalk_lbl


//Split btw small talk and task
label define split_lbl 0 `"all small talk"', add
label define split_lbl 1 `"mostly small talk"', add
label define split_lbl 2 `"evenly split"', add
label define split_lbl 3 `"mostly on tasks"', add
label define split_lbl 4 `"all on tasks"', add
label define split_lbl 99 `"unclear"', add
label values smallTalkvsTask split_lbl

//Is communication symmetric
label define symmetric_lbl 0 `"exclusively dominated by A"', add
label define symmetric_lbl 1 `"mostly dominated by A"', add
label define symmetric_lbl 2 `"equally shared"', add
label define symmetric_lbl 3 `"mostly dominated by B"', add
label define symmetric_lbl 4 `"exclusively dominated by B"', add
label define symmetric_lbl 99 `"unclear"', add
label values commSymmetric symmetric_lbl

//Trying to convince one is knowledgeable
label define convince_lbl 0 `"No"', add
label define convince_lbl 1 `"A tries to convince"', add
label define convince_lbl 2 `"B tries to convince"', add
label define convince_lbl 3 `"both tries to convince"', add
label define convince_lbl 99 `"unclear"', add
label values convinceKnowledgeable convince_lbl

//Discussion of payments
label values paymentMarketIntRate smallTalk_lbl
label values paymentAmazonGift smallTalk_lbl
label values paymenttrustExp smallTalk_lbl
label values paymentLikelihood smallTalk_lbl


//Aproach
label define approach_lbl 0 `"None/Unclear"', add
label define approach_lbl 1 `"Highlight Similarities-Positive"', add
label define approach_lbl 2 `"Highlight Similarities-Negative"', add
label define approach_lbl 3 `"Highlight Differences-Positive"', add
label define approach_lbl 4 `"Highlight Differences-Negative"', add
label values Approach approach_lbl

//Quality coders' view
label define quality_lbl 0 `"Almost all missing"', add
label define quality_lbl 1 `"Most missing"', add
label define quality_lbl 2 `"Some missing"', add
label define quality_lbl 3 `"Few missing"', add
label define quality_lbl 4 `"None missing"', add
label values QualityCodersView quality_lbl

//Preparing data for the merge
duplicates drop Session Pair, force

rename Pair pairinfo
rename Session session

replace session=session-2 if session==29 | session==30 //To match the session numbers in the main data.

//Save the file

save "data/transcription.dta", replace


//Merging with main data file
clear all 
set more off


use "data/mainData.dta"

merge m:1 session pairinfo using "data/transcription.dta"

//Trying to determine whether an individual is Speaker A or Speaker B
gen whichSpeaker=.

*1 stands for Speaker A and 2 stands for Speaker B.
replace whichSpeaker=1 if gender==0 & partnerGender==1 & SpeakerAgender==0 & SpeakerBgender==1
replace whichSpeaker=2 if gender==0 & partnerGender==1 & SpeakerAgender==1 & SpeakerBgender==0
replace whichSpeaker=1 if gender==1 & partnerGender==0 & SpeakerAgender==1 & SpeakerBgender==0
replace whichSpeaker=2 if gender==1 & partnerGender==0 & SpeakerAgender==0 & SpeakerBgender==1

replace whichSpeaker=1 if talkAboutVideos==1 & role==2
replace whichSpeaker=2 if talkAboutVideos==1 & role==1
replace whichSpeaker=1 if talkAboutVideos==2 & role==1
replace whichSpeaker=2 if talkAboutVideos==2 & role==2

replace whichSpeaker=1 if SpeakerAaccent==0 & SpeakerBaccent==1 & (ethnicity==1 | ethnicity==3) & (partnerEthnicity==2 | partnerEthnicity==4 | partnerEthnicity==5 | partnerEthnicity==6)
replace whichSpeaker=2 if SpeakerAaccent==1 & SpeakerBaccent==0 & (ethnicity==1 | ethnicity==3) & (partnerEthnicity==2 | partnerEthnicity==4 | partnerEthnicity==5 | partnerEthnicity==6)
replace whichSpeaker=2 if SpeakerAaccent==0 & SpeakerBaccent==1 & (ethnicity==2 | ethnicity==4 | ethnicity==5 | ethnicity==6) & (partnerEthnicity==1 | partnerEthnicity==3)
replace whichSpeaker=1 if SpeakerAaccent==1 & SpeakerBaccent==0 & (ethnicity==2 | ethnicity==4 | ethnicity==5 | ethnicity==6) & (partnerEthnicity==1 | partnerEthnicity==3)

***We can determine this for 292 individuals out of 436.

save "data/mainDatawTranscription.dta", replace



